package com.orkasgb.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.orkasgb.common.CommonResult;
import com.orkasgb.entity.OrkasgbDictEntity;
import com.orkasgb.service.IOrkasgbDictService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.Serializable;
import java.util.List;

/**
 * 字典信息表(TOrkasgbDict)表控制层
 *
 * @version 1.0.0
 * @since 2024-09-21 23:37:03
 */
@RestController
@RequestMapping("orkasgbDict")
public class OrkasgbDictController {
	
	/**
	 * 服务对象
	 */
	@Resource
	private IOrkasgbDictService orkasgbDictService;
	
	/**
	 * 通过主键查询单条数据
	 *
	 * @param id 主键
	 * @return 单条数据
	 */
	@GetMapping("getOrkasgbDict/{id}")
	public CommonResult<OrkasgbDictEntity> getOrkasgbDict (@PathVariable("id") Serializable id) {
		return CommonResult.ofSuccess(orkasgbDictService.getOrkasgbDict(id));
	}
	
	/**
	 * 通过条件查询多条数据
	 *
	 * @param orkasgbDict 实体查询参数
	 * @return 单条数据
	 */
	@GetMapping("getOrkasgbDictList")
	public CommonResult<List<OrkasgbDictEntity>> getOrkasgbDictList (@ModelAttribute OrkasgbDictEntity orkasgbDict) {
		return CommonResult.ofSuccess(orkasgbDictService.getOrkasgbDictList(orkasgbDict));
	}
	
	/**
	 * 通过条件查询多条数据(分页查询)
	 *
	 * @param orkasgbDict 查询参数
	 * @return 单条数据
	 */
	@GetMapping("getOrkasgbDictPageDataList")
	public CommonResult<IPage<OrkasgbDictEntity>> getOrkasgbDictPageDataList (@ModelAttribute OrkasgbDictEntity orkasgbDict) {
		return CommonResult.ofSuccess(orkasgbDictService.getOrkasgbDictPageDataList(orkasgbDict));
	}
	
	/**
	 * 新增数据
	 *
	 * @param orkasgbDict 实体对象
	 * @return 新增结果
	 */
	@PostMapping("addOrkasgbDict")
	public CommonResult<Integer> addOrkasgbDict (@RequestBody OrkasgbDictEntity orkasgbDict) {
		return CommonResult.ofSuccess(orkasgbDictService.addOrkasgbDict(orkasgbDict));
	}
	
	/**
	 * 修改数据
	 *
	 * @param orkasgbDict 实体对象
	 * @return 修改结果
	 */
	@PutMapping("updateOrkasgbDict")
	public CommonResult<Integer> updateOrkasgbDict (@RequestBody OrkasgbDictEntity orkasgbDict) {
		return CommonResult.ofSuccess(orkasgbDictService.updateOrkasgbDict(orkasgbDict));
	}
	
	/**
	 * 修改或者新增数据
	 *
	 * @param orkasgbDictList 实体对象
	 * @return 操作结果
	 */
	@PostMapping("addOrUpdateOrkasgbDict")
	public CommonResult<Integer> addOrUpdateOrkasgbDict (@RequestBody List<OrkasgbDictEntity> orkasgbDictList) {
		return CommonResult.ofSuccess(orkasgbDictService.addOrUpdateOrkasgbDict(orkasgbDictList));
	}
	
	/**
	 * 删除数据
	 *
	 * @param idList 主键结合
	 * @return 删除结果
	 */
	@DeleteMapping("deleteOrkasgbDictByIds")
	public CommonResult<Integer> deleteOrkasgbDictByIds (@RequestParam("idList") List<Long> idList) {
		return CommonResult.ofSuccess(orkasgbDictService.deleteOrkasgbDictByIds(idList));
	}
	
}

